<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/dayjs/1.10.5/dayjs.min.js"></script>
</head>
<body>
    <div id="demo">
        <h2>显示时间格式化</h2>
        <p>{{startTime | date-format}}</p>
        <p>{{startTime | date-format}}</p>
    </div>
    <script src="../js/vue.js"></script>
    <script>
        // 定义一个过滤器
        Vue.filter('date-format',(value,formstrat="YYYY-MM-DD HH:mm:ss")=>{
            // return moment(value).format(formstrat);
            // return moment(value).format(formstrat || 'YYYY-MM-DD HH:mm:mm');
            return dayjs(value).format(formstrat);
        })
        new Vue({
            el:'#demo',
            data:{
                stratTime:Date.now(),
            }
        })
    </script>
</body>
</html>